/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-16 16:01:17
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-18 06:45:43
 */

import 'package:flutter/material.dart';
import 'package:flutter_data_center/model/camera/camera_model.dart';
import 'package:flutter_data_center/utills/navigator_utils.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../../../constants.dart';
import '../../detail/camera_detail_screen.dart';

class CameraItem extends StatelessWidget {
  const CameraItem({Key key, this.camera, this.pIndex, this.index})
      : super(key: key);
  final CameraItemModel camera;
  final int pIndex;
  final int index;

  @override
  Widget build(BuildContext context) {
    String tag = '${pIndex}_$index';
    return Material(
      color: Colors.transparent,
      child: InkWell(
        onTap: () {
          NavigatorUtils.pushPageByFade(
            context: context,
            targetPage: CameraDetailScreen(tag: tag),
            isReplace: false,
          );
        },
        child: ListTile(
          isThreeLine: false,
          leading: Hero(
            tag: tag,
            child: Container(
                width: 38,
                height: 38,
                padding: EdgeInsets.all(10),
                decoration: BoxDecoration(
                  color: Color(0xffEDD4F5),
                  borderRadius: BorderRadius.circular(defaultRadius),
                ),
                child: SvgPicture.asset("assets/icon/play_icon.svg")),
          ),
          title: Text(
            "${camera.name}${pIndex}_$index",
            style: TextStyle(
              color: Colors.black,
              fontSize: 18,
            ),
          ),
          subtitle: Text(
            camera.ip,
            style: TextStyle(
              color: Color(0xffB5B5B5),
            ),
          ),
          trailing: Icon(Icons.arrow_right),
        ),
      ),
    );
  }
}
